package cn.community.care.module.system.dal.mysql.purchaseinfo;

import java.util.*;

import cn.community.care.framework.common.pojo.PageResult;
import cn.community.care.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.community.care.framework.mybatis.core.mapper.BaseMapperX;
import cn.community.care.module.system.dal.dataobject.purchaseinfo.PurchaseInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.community.care.module.system.controller.admin.purchaseinfo.vo.*;

/**
 * 采购信息 Mapper
 *
 * @author 美妆管理员
 */
@Mapper
public interface PurchaseInfoMapper extends BaseMapperX<PurchaseInfoDO> {

    default PageResult<PurchaseInfoDO> selectPage(PurchaseInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PurchaseInfoDO>()
                .eqIfPresent(PurchaseInfoDO::getPurchaseOrderNum, reqVO.getPurchaseOrderNum())
                .likeIfPresent(PurchaseInfoDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(PurchaseInfoDO::getQuantity, reqVO.getQuantity())
                .eqIfPresent(PurchaseInfoDO::getUnitPrice, reqVO.getUnitPrice())
                .eqIfPresent(PurchaseInfoDO::getTotalAmount, reqVO.getTotalAmount())
                .likeIfPresent(PurchaseInfoDO::getPurchaserName, reqVO.getPurchaserName())
                .betweenIfPresent(PurchaseInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PurchaseInfoDO::getId));
    }

}